package com.dhcc.DRGsHosp.facade.impl.assembler;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.dhcc.DRGsHosp.core.domain.Dictionary;
import com.dhcc.DRGsHosp.facade.dto.DictionaryDTO;

public class DictionaryAssembler {
	
	public static DictionaryDTO  toDTO(Dictionary  dictionary){
		if (dictionary == null) {
			return null;
		}
    	DictionaryDTO result  = new DictionaryDTO();
     	    result.setDicCode(dictionary.getDicCode());
     	    result.setDicDesc(dictionary.getDicDesc());
     	    return result;
	 }
	
	public static List<DictionaryDTO>  toDTOs(Collection<Dictionary>  dictionarys){
		if (dictionarys == null) {
			return null;
		}
		List<DictionaryDTO> results = new ArrayList<DictionaryDTO>();
		for (Dictionary each : dictionarys) {
			results.add(toDTO(each));
		}
		return results;
	}
	
	 public static Dictionary  toEntity(DictionaryDTO  dictionaryDTO){
	 	if (dictionaryDTO == null) {
			return null;
		}
	 	Dictionary result  = new Dictionary();
         result.setDicCode(dictionaryDTO.getDicCode());
         result.setDicDesc(dictionaryDTO.getDicDesc());
 	  	return result;
	 }
	
	public static List<Dictionary> toEntities(Collection<DictionaryDTO> dictionaryDTOs) {
		if (dictionaryDTOs == null) {
			return null;
		}
		
		List<Dictionary> results = new ArrayList<Dictionary>();
		for (DictionaryDTO each : dictionaryDTOs) {
			results.add(toEntity(each));
		}
		return results;
	}
}
